<template>
  <section class="content_right detailPanner" :class="!show ? 'hidden' : null">
    <header class="pannerTop">
      <div>
        <slot name="left"></slot>
      </div>
      <div>
        <slot name="center"></slot>
      </div>
      <div class="close">
        <slot name="right">
        </slot>
        <slot name="action">
          <TopAction />
        </slot>
      </div>
    </header>
    <main class="main" ref="divRef" :style="{
      '--mainWidth': size.width.value + 'px', '--mainHeight': size?.height.value + 'px'
    }">
      <slot name="main"></slot>
    </main>
  </section>
</template>
<script >
import { defineComponent } from 'vue';
import TopAction from './TopAction.vue';
import { ref } from 'vue'
import { useSize } from 'vue-hooks-plus'
export default defineComponent({
  name: "DetailPanner",
  props: {
    show: {
      type: Boolean,
      default: () => true
    }
  },
  components: {
    TopAction
  },
  setup (props, { slots }) {
    const divRef = ref()
    const size = useSize(divRef)
    return {
      divRef,
      size
    }
  }
})
</script>

<style scoped lang="less">
.detailPanner {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background-color: #f7f7f7;
  height: 100%;
  position: relative;

  &.hidden {
    position: absolute;
    left: -200%;
    top: -200%;
    opacity: 0;
    z-index: -99999;
  }

  .pannerTop {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    border: 1px solid #EEEEEE;
    flex-shrink: 0;
    -webkit-app-region: drag;
  }

  .close {
    padding-right: 20px;
    display: flex;
  }

  .main {
    height: calc(100% - 60px);
  }
}
</style>
